<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>课程信息系统</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/app.css">
    <link rel="stylesheet" href="assets/css/pagination.css">
    <script src="assets/js/echarts.min.js"></script>
</head>

<body data-type="index">
    <header class="am-topbar am-topbar-inverse admin-header">
        <div class="am-topbar-brand">
            <a href="index.html" class="tpl-logo">
                <img src="assets/img/logo.png" alt="">
            </a>
        </div>
        <div class="am-icon-list tpl-header-nav-hover-ico am-fl am-margin-right">
        </div>
        <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#topbar-collapse'}">
            <span class="am-sr-only">导航切换</span>
            <span class="am-icon-bars"></span>
        </button>
        <div class="am-collapse am-topbar-collapse" id="topbar-collapse">
            <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">
                <li class="am-dropdown">
                    <div style="margin-top: 20px">
                        <input type="text" id="text" style="width: 230px" placeholder="搜索课程" />
                        <a onclick="search_name()">
                            <i class="glyphicon-header cursor-header am-icon-search" id="search_bars"></i>
                        </a>
                    </div>
                </li>
                <li class="am-hide-sm-only">
                    <a href="javascript:;" id="admin-fullscreen" class="tpl-header-list-link">
                        <span class="am-icon-arrows-alt"></span>
                        <span class="admin-fullText">开启全屏</span>
                    </a>
                </li>
                <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
                    <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
                        <span class="tpl-header-list-user-nick">禁言小张</span>
                        <span class="tpl-header-list-user-ico">
                            <img src="assets/img/user01.png">
                        </span>
                    </a>
                    <ul class="am-dropdown-content">
                        <li>
                            <a class="logout">
                                <span class="am-icon-power-off"></span> 退出</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </header>
    <div class="tpl-page-container tpl-page-header-fixed">
        <div class="tpl-left-nav tpl-left-nav-hover">
            <div class="tpl-left-nav-title">
                用户中心
            </div>
            <div class="tpl-left-nav-list">
                <ul class="tpl-left-nav-menu">
                    <li class="tpl-left-nav-item">
                        <a href="chart.html" class="nav-link tpl-left-nav-link-list">
                            <i class="am-icon-bar-chart"></i>
                            <span>课程信息</span>
                           <!--  <i class="tpl-left-nav-content tpl-badge-danger"></i> -->
                        </a>
                    </li>
                    <li class="tpl-left-nav-item">
                        <a href="recommend_course.html" class="nav-link tpl-left-nav-link-list">
                            <i class="am-icon-bar-chart"></i>
                            <span>推荐课程</span>
                           <!--  <i class="tpl-left-nav-content tpl-badge-danger"></i> -->
                        </a>
                    </li>
                    <li class="tpl-left-nav-item">
                        <a href="statistics.html" class="nav-link active">
                            <i class="am-icon-bar-chart"></i>
                            <span>统计信息</span>
                            <!-- <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i> -->
                        </a>
                    </li>
                    <li class="tpl-left-nav-item">
                        <a href="userinfo.html" class="nav-link tpl-left-nav-link-list">
                            <i class="am-icon-wpforms"></i>
                            <span>用户信息</span>
                            <!-- <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right tpl-left-nav-more-ico-rotate"></i> -->
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="tpl-content-wrapper">
            <div class="tpl-content-page-title">
                课程信息系统
            </div>
            <ol class="am-breadcrumb">
                <li><a href="statistics.html">统计信息</a></li>
                <li class="am-active">用户具体信息统计</li>
            </ol>
            <div class="tpl-portlet">
                <div class="tpl-portlet-title">
                    <div class="tpl-caption font-green ">
                        <i class="am-icon-cloud-download"></i>
                        <span>学习情况</span>
                    </div>
                </div>
                <!--此部分数据请在 js文件夹下中的 app.js 中的 “百度图表A” 处修改数据 插件使用的是 百度echarts-->

                <div class="tpl-echarts" id="tpl-echarts-A" style="height: 100%">
                </div>
            </div>
        </div>
        <script src="assets/js/jquery.min.js"></script>
        <script src="assets/js/amazeui.min.js"></script>
        <script src="./assets/js/app.js"></script>
        <script src="assets/js/raty/jquery.ratyli.min.js"></script>
        <script src="common/jquery.pagination.js"></script>
        <script src="./assets/js/logout.js"></script>
        <script>
        window.onload = function() {

            $.ajax({
                type: "get",
                url: "/author/userInfo",
                success: function(data) {
                    console.log(data)
                    $(".tpl-header-list-user-nick").html(data.data.authorName)
                }

            })

            var myData = [];
            //关注课程
            $.ajax({
                type: "get",
                async: false,
                contentType: "application/json",
                url: "/author/count/followCourse",
                success: function(data) {
                    myData.push(data.data)
                }
            })
            //已验证课程
            var event = {
                isValidate: 1
            }
            $.ajax({
                type: "get",
                async: false,
                data: event,
                contentType: "application/json",
                url: "/author/count/certificateInfo",
                success: function(data) {
                    myData.push(data.data)
                }
            })
            //未验证课程
            var event = {
                isValidate: 0
            }
            console.log(JSON.stringify(event));
            $.ajax({
                type: "get",
                async: false,
                data: event,
                contentType: "application/json",
                url: "/author/count/certificateInfo",
                success: function(data) {
                    myData.push(data.data)
                }
            })
            //已看专题
            $.ajax({
                type: "get",
                async: false,
                contentType: "application/json",
                url: "/author/count/topicInfo",
                success: function(data) {
                    myData.push(data.data)
                }
            })
            //已看演讲
            $.ajax({
                type: "get",
                async: false,
                contentType: "application/json",
                url: "/author/count/lectureInfo",
                success: function(data) {
                    myData.push(data.data)
                }
            })
            console.log(myData);

            var echartsA = echarts.init(document.getElementById('tpl-echarts-A'));
            option = {
                title: {
                    x: 'center',
                    text: '个人学习情况',
                },
                tooltip: {
                    trigger: 'item'
                },
                toolbox: {
                    show: true,
                    feature: {
                        dataView: { show: true, readOnly: false },
                        saveAsImage: { show: true }
                    }
                },
                calculable: true,
                grid: {
                    borderWidth: 0,
                    y: 80,
                    y2: 60
                },
                xAxis: [{
                    type: 'category',
                    show: false,
                    data: ['关注课程', '验证课程', '未验证课程', '已看专题', '已看演讲']
                }],
                yAxis: [{
                    type: 'value',
                    show: false
                }],
                series: [{
                    name: '个人学习情况',
                    type: 'bar',
                    itemStyle: {
                        normal: {
                            color: function(params) {

                                var colorList = [
                                    '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B',
                                    '#FE8463', '#9BCA63', '#FAD860', '#F3A43B', '#60C0DD',
                                    '#D7504B', '#C6E579', '#F4E001', '#F0805A', '#26C0C0'
                                ];
                                return colorList[params.dataIndex]
                            },
                            label: {
                                show: true,
                                position: 'top',
                                formatter: '{b}\n{c}'
                            }
                        }
                    },
                    data: myData,
                    markPoint: {
                        tooltip: {
                            trigger: 'item',
                            backgroundColor: 'rgba(0,0,0,0)',
                            formatter: function(params) {
                                return '<img src="' +
                                    params.data.symbol.replace('image://', '') +
                                    '"/>';
                            }
                        }

                    }
                }]
            };
            echartsA.setOption(option);
        }

        function search_name() {
            var course_name = $("#text").val();
            document.cookie = "keyword_user=" + course_name;
            window.location.href = "/user/course_search.html?name=" + course_name;
        }
        </script>
</body>

</html>